package com.example.demo.jmx;

import java.io.IOException;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.CompilationMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @Description
 * @Author
 * @Date 2020/4/28 15:19
 **/
public class Test {
    private static final Map<String,Object> tokenMap=new HashMap<>(4);
    public static void main(String[] args) throws IOException, InterruptedException {
        tokenMap.put("aa","aa");
        List<MemoryPoolMXBean> memoryPool = ManagementFactory.getMemoryPoolMXBeans();
        BigDecimal bigDecimal = new BigDecimal(7);
        BigDecimal bigDecimal1 = new BigDecimal("7");
        System.out.println(bigDecimal.doubleValue());
        System.out.println(bigDecimal1.doubleValue());
//        final String s = "200007763:11122;sss".replaceAll("200007763:[0-9^;]+", "");
        JVMCPUUsage jvmcpuUsage = new JVMCPUUsage();
        jvmcpuUsage.openMBeanServerConnection();
        jvmcpuUsage.getMXBeanProxyConnections();
        jvmcpuUsage.getJvmThreadUsage();
//        int i=100;
//        while (i>0){
//            i--;
//            float jvmCpuUsage = jvmcpuUsage.getJvmCpuUsage();
//            System.out.println(String.format("%s:%s",new Date(),jvmCpuUsage));
//            final String jvmMemUsage = jvmcpuUsage.getJvmMemUsage();
//            System.out.println(String.format("%s:%s",new Date(),jvmMemUsage));
//            jvmcpuUsage.getJvmThreadUsage();
//            Thread.sleep(5000);
//
//        }

        //获取内存
        MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
        //获取编译信息
        CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
        //获取系统信息
        OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
        //获取运行时信息
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        //获取线程信息
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        //获取类加载信息
        ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
        //获取内存信息
        List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
        //获取gc信息
        List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
    }
}
